package com.yuyou.fn.educational.service.impl;

import com.yuyou.fn.common.util.TimeUtils;
import com.yuyou.fn.common.util.Utils;
import com.yuyou.fn.educational.service.IDivRegService;
import com.yuyou.fn.educational.vo.DivRegInfo;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;
import java.util.List;


@Service
public class DivRegServiceImpl implements IDivRegService{

    public final static Date REG_LIMIT_DATE = Utils.parseDate("2018-03-01 23:59:59" , "yyyy-MM-dd HH:mm:ss");

    @Override
    public List<DivRegInfo> calDivRegInfo(String className, String areaTeamName ,String busTeamName ,String periodName ,String gradeName , String subjectName, Integer lectureAmount , Integer segmentNo) {

/*        //控制广州区域19春季报读报讲次
        if("广州区域".equals(areaTeamName)   && "2019春季".equals(periodName) && "高一高二".contains(gradeName) && lectureAmount > 8 ){
            return Arrays.asList(
                    new DivRegInfo(1, 8 , 1 ,true ) ,
                    new DivRegInfo(9 , lectureAmount , 2 , TimeUtils.now().before(REG_LIMIT_DATE) ? false : true )
            );
        }*/

        return Arrays.asList(new DivRegInfo(1, lectureAmount , 1 ,true ));
    }

    @Override
    public DivRegInfo getCurrentDivInfo(List<DivRegInfo> divRegInfos) {
        DivRegInfo willDivRegInfo = divRegInfos.get(0);
        if(divRegInfos.size() > 1 && divRegInfos.get(1).isAvailableReg() ){
            willDivRegInfo = divRegInfos.get(1);
        }
        return willDivRegInfo;
    }
}
